{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "85582489",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:········\n",
      "游戏开始\n",
      "guess_digit50\n",
      "往大了猜\n",
      "guess_digit60\n",
      "往小了猜\n",
      "guess_digit55\n",
      "往大了猜\n",
      "guess_digit58\n",
      "往小了猜\n",
      "guess_digit57\n",
      "猜对了\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "hide_card = int(getpass.getpass(\"hide_card:\"))  ## 隐藏输入的东西\n",
    "count = 0\n",
    "\n",
    "if hide_card <100 and hide_card >0 :\n",
    "    print(\"游戏开始\")\n",
    "    while True:\n",
    "        if count <5:  ## count>5 时游戏结束\n",
    "            guess_digit = int(input(\"guess_digit\"))  ## 猜数字的人\n",
    "            if guess_digit == hide_card:\n",
    "                print(\"猜对了\")\n",
    "                break  ## 猜对后停止\n",
    "            elif guess_digit > hide_card:\n",
    "                print(\"往小了猜\")\n",
    "            else:\n",
    "                print(\"往大了猜\")\n",
    "            count = count+1\n",
    "        else:\n",
    "            print(\"猜那么多次都不对，你个sb\")\n",
    "            print(\"正确答案是：%s\"%hide_card)  ## 打印正确答案\n",
    "            break\n",
    "else:\n",
    "    print(\"输入范围为0-99\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c2ce0f0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
